package cn.tudu.boot21.controller;

import cn.tudu.boot21.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HelloController {
   /* @RequestMapping("/hello")
    public void hello(HttpServletResponse response) throws IOException {
         response.setContentType("text/html;charset=utf-8");
        PrintWriter pw = response.getWriter();
        pw.print("<hr>");
        pw.print("测试成功");
        pw.close();
    }*/
    @RequestMapping("hello")
    @ResponseBody
    //Spring mvc框架 提供的注解,可以通过返回值的方式,给客户端响应数据
    public String hello(){
        return "测试成功222";
    }
    @RequestMapping("/param1")
    @ResponseBody
    public String param1(HttpServletRequest request){
        String info = request.getParameter("info");
        return "接受到了参数"+info;
    }
    @RequestMapping("/param2")
    @ResponseBody
    public String param2(String name,int age){
        return "接受到参数:姓名:"+name+":年龄"+age;
    }
    @RequestMapping("/param3")
    @ResponseBody
    public String param3(Emp emp){
       return emp.toString();
    }
}
